<?php 
    session_start(); 
    include 'db_connection.php';

    $sql = 'SELECT * FROM educational_resources ORDER BY id DESC ';
    $result = mysqli_query($conn, $sql);
    $list = [];
    if ($result) {
        while($row = $result->fetch_assoc()) {
            $list[] = $row;
        }
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>教育资源共享</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<? require 'common/nav.php'; ?>
<main class="educational">
    <h1>教育资源共享</h1>
    <div class="p-box">
        <?php foreach ($list as $row) { ?>
        <div class="resource">
            <h2><?php echo $row['resource_name']; ?></h2>
            <p><?php echo $row['description']; ?></p>
            <button><a href="/<?php echo $row['file_path']; ?>">下载资源</a></button>
        </div>
        <?php } ?>
    </div>
</main>
</body>
</html>